using System;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace OpenAI.Chat
{
    public sealed class Delta
    {
        /// <summary>
        /// The <see cref="OpenAI.Role"/> of the author of this message.
        /// </summary>
        
        [JsonProperty("role")]
        public Role Role { get; private set; }

        /// <summary>
        /// The contents of the message.
        /// </summary>
        
        [JsonProperty("content")]
        public string Content { get; private set; }

        /// <summary>
        /// The tool calls generated by the model, such as function calls.
        /// </summary>
        
        [JsonProperty("tool_calls")]
        public IReadOnlyList<Tool> ToolCalls { get; private set; }

        /// <summary>
        /// Optional, The name of the author of this message.<br/>
        /// May contain a-z, A-Z, 0-9, and underscores, with a maximum length of 64 characters.
        /// </summary>
        
        [JsonProperty("name")]
        public string Name { get; private set; }

        /// <summary>
        /// The function that should be called, as generated by the model.
        /// </summary>
        
        [Obsolete("Replaced by ToolCalls")]
        [JsonProperty("function_call")]
        public Function Function { get; private set; }

        public override string ToString() { return Content ?? string.Empty; }

        public static implicit operator string(Delta delta) { return delta.ToString(); }
    }
}
